import Vue from 'vue'
import Vuex from 'vuex'
import { setItem, getItem, removeItem } from '@/util/storage.js'

Vue.use(Vuex)

const TOUTIAO_USER = 'TOUTIAO_USER'

export default new Vuex.Store({
  state: {
    // 用户的登录状态信息
    user: getItem(TOUTIAO_USER)
    // user: null
  },
  mutations: {
    setUser (state, data) {
      state.user = data
      setItem(TOUTIAO_USER, state.user)
    },
    removeUser (state) {
      state.user = null
      removeItem(TOUTIAO_USER)
    }
  },
  actions: {
  },
  modules: {
  }
})
